package ar.com.ford.it.fullEconomics.persistence.dao.query;

import oracle.toplink.expressions.Expression;
import oracle.toplink.expressions.ExpressionBuilder;
import ar.com.ford.it.fullEconomics.persistence.dto.Teesm01Currency;
import com.ford.it.persistence.impl.toplink.CustomExpressionFactory;

public class CurrencyFindQuery implements CustomExpressionFactory {

    public Expression createExpression(ExpressionBuilder builder,
                                       Object[] parameters) {
        Expression exp = null;
        Teesm01Currency currency = (Teesm01Currency) parameters[0];
        String name = null;
        
        name = currency.getEesm01CurrencyCodeC();
        
        if (name == null) {
            name = "%";
        } else {
            name += "%";
        }
        
        if (name != null) {
            exp = builder.get("eesm01CurrencyCodeC").toLowerCase().like(
                    name.toLowerCase());
        }

        return exp;
    }

}
